﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Fusion;

namespace Fusion.Interface
{
	public class ToggleButton : Control
	{
		Image image;

		Rectangle offRect;
		Rectangle onRect;

		public bool isChecked;

		public ToggleButton( Vector2 center, Vector2 Size, string texture, Rectangle on, Rectangle off, VoidDelegate ClickEvent )
		{
			position = center;
			size = Size;

			image = new Image( texture );

			Clicked += ClickEvent;
			Clicked += Click;

			offRect = off;
			onRect = on;
		}

		void Click()
		{ isChecked = !isChecked; }

		public override void Draw()
		{
			if( hidden == true )
				return;

			base.Draw();
			Rectangle dest = new Rectangle( (int)( Position.X ), (int)( Position.Y  ), (int)Size.X, (int)Size.Y );
			Engine.spriteBatch.Draw( image.Texture, dest, isChecked == true ? onRect : offRect, Color.White );
		}
	}
}
